package com.henry;

import com.henry.filter.HttpBasicAuthorizeAttribute;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.ArrayList;
import java.util.List;

@EnableTransactionManagement
@MapperScan(basePackages = {"com.henry.mapper"})
@SpringBootApplication
public class SpringbootDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringbootDemoApplication.class, args);
	}

	@Bean
	public FilterRegistrationBean filterRegistrationBean(){
		FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
		HttpBasicAuthorizeAttribute httpBasicAuthorizeAttribute = new HttpBasicAuthorizeAttribute();
		filterRegistrationBean.setFilter(httpBasicAuthorizeAttribute);
		List<String> urlPatterns = new ArrayList<>();
		urlPatterns.add("/hello/user/*");
		filterRegistrationBean.setUrlPatterns(urlPatterns);
		return filterRegistrationBean;
	}

}
